package com.song.composejoke

import android.graphics.fonts.FontStyle
import android.os.Bundle
import android.webkit.WebView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

class WebActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.web)

        supportActionBar?.hide()

        val title = intent.getStringExtra("title")
        val url = intent.getStringExtra("url")

        val tvTitle = findViewById<TextView>(R.id.tvTitle)
        val webView = findViewById<WebView>(R.id.webView)

        tvTitle.text = title
        webView.loadUrl(url!!)

        val composeView: ComposeView = findViewById(R.id.composeView)
        composeView.setContent {
            if (title != null) {
                Text(
                    text = title,
                    textAlign = TextAlign.Center,
                    style = TextStyle(fontSize = 18.sp),
                    modifier = Modifier.padding(10.dp)
                )
            }
        }
    }
}